package com.kyle.pagingdemo

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import com.kyle.pagingdemo.databinding.FragmentMainBinding

/**
 * author: liliang
 * date: 4/24/21 8:50 AM
 * desc:
 */
class MainFragment : Fragment(R.layout.fragment_main) {

    private var _binding: FragmentMainBinding? = null
    private val binding: FragmentMainBinding get() = _binding!!


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        _binding = FragmentMainBinding.bind(view)
        val url = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fyouimg1.c-ctrip.com%2Ftarget%2Ftg%2F004%2F531%2F381%2F4339f96900344574a0c8ca272a7b8f27.jpg&refer=http%3A%2F%2Fyouimg1.c-ctrip.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1621848633&t=2dda2238caa4ca44cc7b9793d000cca6"
        Glide.with(binding.imageSmall.context).load(url)
            .into(binding.imageSmall)
        binding.imageSmall.setOnClickListener {
            val bundle = Bundle()
            bundle.putString("url", url)
            val extras = FragmentNavigatorExtras(binding.imageSmall to "image_big")
//            findNavController().navigate(
//                R.id.action_mainFragment_to_imageFragment,
//                bundle,
//                null,
//                extras
//            )
        }
    }


    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }

}